package ${package.Controller};

import ${package.Entity}.${entity};
import ${package.Service}.${table.serviceName};
import com.cly.result.JsonRequest;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
* ${table.comment}业务层实现
* @author ${author}
* <p>
* ${date}
*/
@RestController
@RequestMapping("/${table.entityPath}")
@Tag(name = "${table.comment}控制类", description = "${table.comment}操作访问接口")
public class ${table.controllerName} {

    /**
    *  注入${table.comment}业务层
    */
    @Resource
    private ${table.serviceName} ${table.entityPath}Service;

    /**
    *  根据条件查询${table.comment}信息
    *  @param ${table.entityPath} 条件
    *  @return JSON
    */
    @GetMapping("/list")
    @Operation(summary = "根据条件查询${table.comment}信息")
    public JsonRequest<List<${entity}>> look${entity}(
        @Parameter(description = "页码", required = true)
        @RequestParam Integer current,
        @Parameter(description = "页长", required = true)
        @RequestParam Integer size,
        @Parameter(description = "${table.comment}条件", required = true)
        ${entity} ${table.entityPath}){
        return ${table.entityPath}Service.look${entity}(current, size, ${table.entityPath});
    }

    /**
    *  新增一条${table.comment}信息
    *  @param ${table.entityPath} ${table.comment}信息
    *  @return JSON
    */
    @PostMapping
    @Operation(summary = "新增一条${table.comment}信息")
    public JsonRequest<Integer> addOne${entity}(
        @Parameter(description = "${table.comment}信息", required = true)
        @RequestBody ${entity} ${table.entityPath}){
        return ${table.entityPath}Service.addOne${entity}(${table.entityPath});
    }

    /**
    *  修改一条${table.comment}信息
    *  @param ${table.entityPath} ${table.comment}信息
    *  @return JSON
    */
    @PutMapping
    @Operation(summary = "修改一条${table.comment}信息")
    public JsonRequest<Integer> updateOne${entity}(
            @Parameter(description = "${table.comment}信息", required = true)
            @RequestBody ${entity} ${table.entityPath}){
        return ${table.entityPath}Service.updateOne${entity}(${table.entityPath});
    }

    /**
    *  批量删除${table.comment}信息
    *  @param ids ${table.comment}id列表
    *  @return JSON
    */
    @DeleteMapping
    @Operation(summary = "批量删除${table.comment}信息")
    public JsonRequest<Integer> delete${entity}s(
                @Parameter(description = "${table.comment}id列表", required = true)
                @RequestBody List<Long> ids){
        return ${table.entityPath}Service.delete${entity}s(ids);
    }

}